﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
//using Sherwood.SignOn.Server.Models.Data;
//using Sherwood.SignOn.Server;
//using Sherwood.SignOn.Server.Tests;


//namespace Sherwood.SignOn.Client.Tests
//{
//    [TestClass]
//    public class SsoClientTest : TestBase
//    {
//        [TestMethod]
//        public void No_Session_Test()
//        {
//            //Arrange
//            SignOnClient client = new SignOnClient();

//            //Act
//            string userSessionId = client.UserAccountId;

//            //Assert
//            Assert.IsNull(userSessionId);
            

//        }


//        [TestMethod]
//        public void Create_Session_Test()
//        {
//            //Arrange
//            SignOnClient client = new SignOnClient();
            
//            //Simulate server operations.
//            IUserAccount user = Sherwood.SignOn.Server.Tests.TestHelper.CreateVerifiedDummyUser("username", "password");
//            //Simulate sign in request
//            Sherwood.SignOn.Server.Models.ViewModels.SignInViewModel serverViewModel = new Sherwood.SignOn.Server.Models.ViewModels.SignInViewModel();
//            serverViewModel.UserName = "username";
//            serverViewModel.Password = "password";
//            serverViewModel.ReturnUrl = "{signinticket}|{signinsignature}";
//            serverViewModel.ClientSessionId = client.SessionRepository.CreateSession();
//            //Simulate sign in
//            serverViewModel.AuthenticateUser(new System.Web.Mvc.ModelStateDictionary());
//            //Generate sign in tickets
//            ISignOnSession session = AppData.UserSessions.All.FirstOrDefault();
//            string sisignature = "";
//            string siticket = session.GetSignInTicket(serverViewModel.ClientSessionId, out sisignature);


//            //Act
//            client.ClientSignOn(siticket, sisignature);
//            string userAccountId = client.UserAccountId;

//            //Assert
//            Assert.IsTrue(userAccountId.Equals(user.Id.ToString()));

//        }



//        [TestMethod]
//        public void SignOut_Session_Test()
//        {
//            //Arrange
//            SignOnClient client = new SignOnClient();
//            //Simulate server operations.
//            //Initialize server domain
//            IUserAccount user = Sherwood.SignOn.Server.Tests.TestHelper.CreateVerifiedDummyUser("username", "password");
//            //Simulate sign out request
//            Sherwood.SignOn.Server.Models.ViewModels.SignInViewModel serverViewModel = new Sherwood.SignOn.Server.Models.ViewModels.SignInViewModel();
//            serverViewModel.UserName = "username";
//            serverViewModel.Password = "password";
//            serverViewModel.ClientSessionId = client.SessionRepository.CreateSession();
//            //Simulate sign in
//            serverViewModel.AuthenticateUser(new System.Web.Mvc.ModelStateDictionary());
//            //Generate sign out tickets
//            ISignOnSession session = AppData.UserSessions.All.FirstOrDefault();
//            string sisignature = "";
//            string siticket = session.GetSignInTicket(serverViewModel.ClientSessionId, out sisignature);
//            string sosignature = "";
//            string soticket = session.GetSignOutTicket(serverViewModel.ClientSessionId, out sosignature);
            
//            //Act
//            client.ClientSignOn(siticket, sisignature);
//            string userAccountIdBefore = client.UserAccountId;
//            client.ClientSignOut(soticket, sosignature);
//            string userAccountIdAfter = client.UserAccountId;

//            //Assert
//            Assert.IsTrue(userAccountIdBefore.Equals(user.Id.ToString()));
//            Assert.IsTrue(userAccountIdAfter == null);

//        }


//        [TestMethod]
//        public void SignOut_Session_With_ClientID_Test() 
//        {
//            //Arrange
//            SignOnClient client = new SignOnClient();
//            //Simulate server operations.
//            //Initialize server domain

//            string clientSessionID = Guid.NewGuid().ToString();
//            IUserAccount user = Sherwood.SignOn.Server.Tests.TestHelper.CreateVerifiedDummyUser("username", "password");
//            //Simulate sign out request
//            Sherwood.SignOn.Server.Models.ViewModels.SignInViewModel serverViewModel = new Sherwood.SignOn.Server.Models.ViewModels.SignInViewModel();
//            serverViewModel.UserName = "username";
//            serverViewModel.Password = "password";
//            serverViewModel.ClientSessionId = clientSessionID;
//            serverViewModel.ClientSessionId = client.SessionRepository.CreateSession();
//            //Simulate sign in
//            serverViewModel.AuthenticateUser(new System.Web.Mvc.ModelStateDictionary());
//            //Generate sign out tickets
//            ISignOnSession session = AppData.UserSessions.All.FirstOrDefault();
//            string sisignature = "";
//            string siticket = session.GetSignInTicket(serverViewModel.ClientSessionId, out sisignature);
//            string sosignature = "";
//            string soticket = session.GetSignOutTicket(serverViewModel.ClientSessionId, out sosignature);

//            //Act
//            client.ClientSignOn(siticket, sisignature);
//            string userAccountIdBefore = client.UserAccountId;
//            client.ClientSignOut(soticket, sosignature);
//            string userAccountIdAfter = client.UserAccountId;

//            //Assert
//            Assert.IsTrue(userAccountIdBefore.Equals(user.Id.ToString()));
//            Assert.IsTrue(userAccountIdAfter == null);

//        }
//    }
//}
